/**
* Created by wust on 2020-07-15 14:14:39.
*/
<template>
	<el-form ref="formModel" :model="formModel" :rules="rules" label-width="120px" style="width:70%;"
	 @submit.native.prevent>
		<el-form-item label="order_no" prop="orderNo">
			<el-input v-model="formModel.orderNo"></el-input>
		</el-form-item>
		<el-form-item label="buyer_id" prop="buyerId">
			<el-input v-model="formModel.buyerId"></el-input>
		</el-form-item>
		<el-form-item label="buyer_name" prop="buyerName">
			<el-input v-model="formModel.buyerName"></el-input>
		</el-form-item>
		<el-form-item label="buyer_telephone" prop="buyerTelephone">
			<el-input v-model="formModel.buyerTelephone"></el-input>
		</el-form-item>
		<el-form-item label="buyer_address" prop="buyerAddress">
			<el-input v-model="formModel.buyerAddress"></el-input>
		</el-form-item>
		<el-form-item label="total_amount" prop="totalAmount">
			<el-input v-model="formModel.totalAmount"></el-input>
		</el-form-item>
		<el-form-item label="status" prop="status">
			<el-input v-model="formModel.status"></el-input>
		</el-form-item>
		<el-form-item label="pay_type" prop="payType">
			<el-input v-model="formModel.payType"></el-input>
		</el-form-item>
		<el-form-item label="pay_status" prop="payStatus">
			<el-input v-model="formModel.payStatus"></el-input>
		</el-form-item>
		<el-form-item label="business_serial_number" prop="businessSerialNumber">
			<el-input v-model="formModel.businessSerialNumber"></el-input>
		</el-form-item>
		<el-form-item label="is_deleted" prop="isDeleted">
			<el-input v-model="formModel.isDeleted"></el-input>
		</el-form-item>

		<el-form-item style="text-align: left;">
			<el-button type="primary" @click="onSubmit('formModel')" :loading="submitting">提交</el-button>
		</el-form-item>
	</el-form>
</template>
<script>
import Vue from 'vue'

export default {
  name: 'order-update',
  props: ['selectedModel'],
  data () {
    return {
      submitting: false,
      formModel: {
        id: null,
        orderNo: null,
        buyerId: null,
        buyerName: null,
        buyerTelephone: null,
        buyerAddress: null,
        totalAmount: null,
        status: null,
        payType: null,
        payStatus: null,
        businessSerialNumber: null,
        isDeleted: null

      },
      rules: {}
    }
  },
  created: function () {
    this.formModel = this.selectedModel
  },
  methods: {
    onSubmit: function (formData) {
      this.$refs[formData].validate((valid) => {
        if (!valid) {} else {
          Vue.$ajax({
            method: 'put',
            url: Vue.$orderServerURL + '/web/v1/OrderController',
            data: this.formModel
          }).then(res => {
            if (res.data.flag !== 'SUCCESS') {
              if (!Vue.$isNullOrIsBlankOrIsUndefined(res.data.message)) {
                this.$message({
                  message: res.data.message,
                  type: 'warning'
                })
              }
            } else {
              this.$message({
                message: res.data.message,
                type: 'success'
              })
            }
          })
        }
      })
    }
  }
}
</script>
